<?php
    include_once "../../inc/config.inc.php";
    include_once '../../inc/mysql.inc.php';
    include_once "../inc/tool.inc.php";

    $template["title"] = "父版块添加页";
    $template["keyword"] = "父版块添加页";
    $template["description"] = "父版块添加页";
    
    $link = connect();

    if(isset($_POST['submit'])){
        $check_flag = "add";

        // 验证填写信息是否成功 
        include_once '../inc/check_father_module.inc.php';
        
        $query = "insert into kuse_father_module(module_name, sort) values('{$_POST['module_name']}', '{$_POST['sort']}')";

        execute($link, $query);

        if(mysqli_affected_rows($link)==1){
            skip("father_module.php", "ok", "恭喜你，添加成功！");
        }else{
            skip("father_module_add.php", "error", "对不起，添加失败，请重试！");
        }
    }
?>
<?php include_once "../inc/header.inc.php";?>

<div id="main">
    <div class="title">添加父版块</div>

    <form method="post">
        <table class="au">
            <tr>
                <td>版块名称</td>
                <td><input name="module_name" type="text" /></td>
                <td>版块名称不得为空，最大不能超过66个字符</td>
            </tr>
            <tr>
                <td>排序</td>
                <td><input name="sort" value='0' type="text" /></td>
                <td>填写一个数字即可</td>
            </tr>
        </table>

        <input type="submit" class="btn" name="submit" value="添加">
    </form>
</div>
<?php include_once "../inc/footer.inc.php";?>